document.onload = setTimeout(function () {
  play();
}, 100);
function timeChangeM(value) {
  var m = (value - value % 60) / 60;
  return m;
}
function timeChangeS(value) {
  var s = value % 60;
  s = parseInt(s);
  return s;
}
function play() {
  var $audio = document.getElementsByClassName('audio-file')[0],
    $dTime = document.getElementsByClassName('dTime')[0],
    $cTime = document.getElementsByClassName('cTime')[0];
    playTime = $audio.currentTime,
    duration = $audio.duration,
    playBlock = $audio.paused;
  var hiPlay = new Vue({
    el: '.player',
    data: {
      dTimeM: 0,
      dTimeS: 0,
      cTimeM: 0,
      cTimeS: 0,
      playStatus: playBlock,
    },
    methods: {
      play: function() {
        if ($audio.paused) {
          $audio.play();
        }else {
          $audio.pause();
        }
        this.playStatus = $audio.paused;
      }
    }
  });
  var timeUpdata = {
    dUpdata: function() {
      var dTime = $audio.duration;
      hiPlay.dTimeM = timeChangeM(dTime);
      hiPlay.dTimeS = timeChangeS(dTime);
    },
    cUpdata: function() {
      var cTime = $audio.currentTime;
      hiPlay.cTimeM = timeChangeM(cTime);
      hiPlay.cTimeS = timeChangeS(cTime);
    },
  };
  var dTimeUpdata = function() {
    if (isNaN(duration)) {
      setTimeout(function () {
        timeUpdata.dUpdata();
      }, 500);
    }
    else {
      timeUpdata.dUpdata();
    }
  }();
  var cTimeUpdata = function() {
    if (hiPlay.playStatus) {
      setInterval(function () {
        timeUpdata.cUpdata();
      }, 1000);
    }else {
      timeUpdata.cUpdata();
    }
  }();
}
